package lesson;

import java.util.Arrays;
import java.util.Properties;

public class StringProperties {

    public static void main(String[] args) {

        // 将下面字符串?后面的键值对保存到proerties文件中
        String url = "http://www.lovo.com/index?name=aaaaaa&age=20&gender=男";
        System.out.println(url);

//        int s1 = url.indexOf("?");
//        System.out.println(s1);

        String s1 = url.substring(url.indexOf("?") + 1); //一个参数直接取到最后面，两个参数确定区间
        System.out.println(s1);

        String[] s2 = s1.split("&");
        System.out.println(Arrays.toString(s2));

        Properties properties = new Properties();


        for (int i = 0; i < s2.length; i++) {
            String[] s3 = s2[i].split("=");
//            System.out.println(Arrays.toString(s3));
            properties.setProperty(s3[0], s3[1]);
        }
        PropertiesUtil.propertiesReadMethod("1.properties");
        PropertiesUtil.propertiesWriteMethod("1.properties", properties);
        System.out.println(properties.getProperty("name"));

        System.out.println(properties.getProperty("habit"));


    }
}
